package cn.zs.supply.common.utils;



import org.apache.commons.lang3.ArrayUtils;

import java.util.Collection;
import java.util.Map;
public abstract class ObjectUtils {
    /** 是否为null、空字符串、空数组、空list、空map。 */
    public static boolean isEmptyObject(Object object) {
        if (object == null) {
            return true;
        } else if (object instanceof String) {
            return ((String) object).isEmpty();
        } else if (object.getClass().isArray()) {
            return ArrayUtils.isEmpty((Object[]) object);
        } else if (object instanceof Collection) {
            return ((Collection) object).isEmpty();
        } else if (object instanceof Map) {
            return ((Map) object).isEmpty();
        } else {
            return false;
        }
    }

    public static <T> T isNullSetDefault(T t,T d){
        if (ObjectUtils.isEmptyObject(t)){
            return d;
        }
        return t;
    }

}
